class CouncillorsController < ApplicationController
  # GET /councillors
  # GET /councillors.xml
  def index
    @councillors = Councillor.find(:all)

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @councillors }
	  format.rss
    end
  end

  # GET /councillors/1
  # GET /councillors/1.xml
  def show
    @councillor = Councillor.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @councillor }
    end
  end

  # GET /councillors/new
  # GET /councillors/new.xml
  def new
    @councillor = Councillor.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @councillor }
    end
  end

  # GET /councillors/1/edit
  def edit
    @councillor = Councillor.find(params[:id])
  end

  # POST /councillors
  # POST /councillors.xml
  def create
    @councillor = Councillor.new(params[:councillor])

    respond_to do |format|
      if @councillor.save
        flash[:notice] = 'Councillor was successfully created.'
        format.html { redirect_to(@councillor) }
        format.xml  { render :xml => @councillor, :status => :created, :location => @councillor }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @councillor.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /councillors/1
  # PUT /councillors/1.xml
  def update
    @councillor = Councillor.find(params[:id])

    respond_to do |format|
      if @councillor.update_attributes(params[:councillor])
        flash[:notice] = 'Councillor was successfully updated.'
        format.html { redirect_to(@councillor) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @councillor.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /councillors/1
  # DELETE /councillors/1.xml
  def destroy
    @councillor = Councillor.find(params[:id])
    @councillor.destroy

    respond_to do |format|
      format.html { redirect_to(councillors_url) }
      format.xml  { head :ok }
    end
  end
end
